package com.haha.im

import com.haha.im.contract.LoginContract
import kotlinx.android.synthetic.main.activity_login.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast

class LoginActivity:BaseActivity(),LoginContract.View {
    override fun getLayoutResId(): Int = R.layout.activity_login
    override fun onUserNameError() {
        userName.error = getString(R.string.user_name_error)
    }

    override fun onPasswordError() {
        password.error = getString(R.string.password_error)
    }

    override fun onStartLogin() {
        showProgress(getString(R.string.logging))
    }

    override fun onLoggedSuccess() {
        //进入主界面
        hideProgress()
        startActivity<MainActivity>()
        finish()
    }

    override fun onLoggedFailed() {
        hideProgress()
        toast(getString(R.string.login_failed))
    }
}